View Javadoc

1   /**
2    * Copyright 2008 WebPhotos
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  /*
17   * To change this template, choose Tools | Templates
18   * and open the template in the editor.
19   */
20  package net.sf.webphotos.model;
21  
22  import java.io.Serializable;
23  import javax.persistence.*;
24  import net.sf.webphotos.entity.HasID;
25  
26  /**
27   *
28   * @author Guilhe
29   */
30  @Entity
31  @Table(name = "CATEGORIAS")
32  @NamedQueries({
33      @NamedQuery(name = "CategoryVO.findByCategoriaID", query = "SELECT c FROM CategoryVO c WHERE c.categoriaID = :categoriaID"),
34      @NamedQuery(name = "CategoryVO.findByNmcategoria", query = "SELECT c FROM CategoryVO c WHERE c.nmcategoria = :nmcategoria")})
35  public class CategoryVO implements Serializable, HasID<Integer> {
36  
37      private static final long serialVersionUID = 1L;
38      
39      @Id
40      @Column(name = "CATEGORIAID", nullable = false)
41      @GeneratedValue(strategy=GenerationType.IDENTITY)
42      private Integer categoriaID;
43      
44      @Column(name = "NMCATEGORIA", nullable = false)
45      private String nmcategoria;
46      
47      @ManyToOne(optional = true)
48      @JoinColumn(name = "CATEGORIAPAI")
49      private CategoryVO categoriaPai;
50  
51      @Deprecated
52      public CategoryVO() {
53      }
54  
55      @Deprecated
56      public CategoryVO(Integer categoriaID) {
57          this.categoriaID = categoriaID;
58      }
59  
60      @Deprecated
61      public CategoryVO(Integer categoriaID, String nmcategoria) {
62          this(categoriaID);
63          this.nmcategoria = nmcategoria;
64      }
65  
66      public CategoryVO(String nmcategoria) {
67          this.nmcategoria = nmcategoria;
68      }
69  
70      public CategoryVO(String nmcategoria, CategoryVO categoriaPai) {
71          this(nmcategoria);
72          this.categoriaPai = categoriaPai;
73      }
74      
75      public Integer getCategoriaID() {
76          return categoriaID;
77      }
78  
79      public void setCategoriaID(Integer categoriaid) {
80          this.categoriaID = categoriaid;
81      }
82  
83      public String getNmcategoria() {
84          return nmcategoria;
85      }
86  
87      public void setNmcategoria(String nmcategoria) {
88          this.nmcategoria = nmcategoria;
89      }
90  
91      /**
92       * @return the categoriaPai
93       */
94      public CategoryVO getCategoriaPai() {
95          return categoriaPai;
96      }
97  
98      /**
99       * @param categoriaPai the categoriaPai to set
100      */
101     public void setCategoriaPai(CategoryVO categoriaPai) {
102         this.categoriaPai = categoriaPai;
103     }
104 
105     @Override
106     public int hashCode() {
107         int hash = 0;
108         hash += (categoriaID != null ? categoriaID.hashCode() : 0);
109         return hash;
110     }
111 
112     @Override
113     public boolean equals(Object object) {
114         // TODO: Warning - this method won't work in the case the id fields are not set
115         if (!(object instanceof CategoryVO)) {
116             return false;
117         }
118         CategoryVO other = (CategoryVO) object;
119         if ((this.categoriaID == null && other.categoriaID != null) || (this.categoriaID != null && !this.categoriaID.equals(other.categoriaID))) {
120             return false;
121         }
122         return true;
123     }
124 
125     @Override
126     public String toString() {
127         return this.getClass().getCanonicalName() + "[categoriaid=" + categoriaID + "]";
128     }
129 
130     @Override
131     public Integer getId() {
132         return categoriaID;
133     }
134 }